using System;
using System.Collections.Generic;
using System.Text;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Graphics.Particle;

using FlatRedBall.Math.Geometry;
using FlatRedBall.Math.Splines;
using BitmapFont = FlatRedBall.Graphics.BitmapFont;
using Cursor = FlatRedBall.Gui.Cursor;
using GuiManager = FlatRedBall.Gui.GuiManager;

#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;


#endif

namespace MultiplayerTD.Entities
{
	public partial class Tower
	{
        double lastShootTime = 0;
        bool firstShoot = true;

		private void CustomInitialize()
		{
            
		}

        private void Shoot(Mob mob)
        {
            Bullet newBullet = Factories.BulletFactory.CreateNew();
            newBullet.X = this.X;
            newBullet.Y = this.Y;
            newBullet.Target = mob;
        }

        public void Shooting(Mob mob)
        {
            if(firstShoot || TimeManager.CurrentTime - lastShootTime >= ShootingSpeed)
            {
                firstShoot = false;
                lastShootTime = TimeManager.CurrentTime;
                Shoot(mob);
            }
        }

        private void setBacklight()
        {
            if (CurrentState == VariableState.Selected ||
                CurrentState == VariableState.Disable ||
                CurrentState == VariableState.MayBuild)
                return;

            if (InputManager.Mouse.IsOn3D(SpriteFrameInstance, true))
            {
                SpriteFrameInstance.Blue = 0.3f;
                SpriteFrameInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Add;
            }
            else
            {
                SpriteFrameInstance.Blue = 0.0f;
                SpriteFrameInstance.ColorOperation = FlatRedBall.Graphics.ColorOperation.Add;
            }
        }

		private void CustomActivity()
		{
            setBacklight();
		}

		private void CustomDestroy()
		{


		}

        private static void CustomLoadStaticContent(string contentManagerName)
        {


        }
	}
}
